import unittest
from base.get_driver import GetDriver
from page.page_header import PageHeader
from page.page_login import PageLogin
from page.page_good_list import PageGoodList
from page.page_good_detail import PageGoodDetail
from page.page_card import PageCard
class TestCard(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        cls.driver = GetDriver().get_driver()
        cls.page_header = PageHeader(cls.driver)
        cls.page_good_list = PageGoodList(cls.driver)
        cls.page_good_detail = PageGoodDetail(cls.driver)
        cls.page_card = PageCard(cls.driver)
        cls.page_login = PageLogin(cls.driver)
        cls.page_login.page_login_success()
        cls.page_login.base_index()

    def tearDown(self):
        # 关闭连接
        GetDriver().quit_driver()

    def test_add_card(self):
        self.page_header.click_nav_link_1()
        self.page_good_list.click_product_item_name()
        self.page_good_detail.page_click_add_card()
        msg = self.page_card.get_iframe_text()
        self.assertEqual(msg, "添加成功")
        self.page_card.close_iframe_window()